package com.cn.lp.ai.factory;

import com.cn.lp.ai.chat.AiChatService;
import com.cn.lp.ai.factory.constants.LpAiFactoryType;
import com.cn.lp.ai.factory.domain.chat.LpAiChatServiceHandler;
import com.cn.lp.ai.factory.domain.model.OpenAiModel;
import com.cn.lp.ai.factory.domain.vector.LpAiVectorServiceHandler;
import com.cn.lp.ai.factory.domain.vector.LpVectorType;
import com.cn.lp.ai.vector.AiVectorService;
import org.springframework.ai.autoconfigure.qianfan.QianFanConnectionProperties;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Optional;

@Service
public class InitService {

//    @Autowired
    private ChatDemoController chatDemoController;

    @Autowired
    private WenxinChatModel chatModel;

    @Autowired
    private LpAiChatServiceHandler aiChatServiceHandler;

    @Autowired
    private LpAiVectorServiceHandler aiVectorServiceHandler;

    public void init() {
        Optional<AiVectorService> aiVectorServiceOpt = aiVectorServiceHandler.getByType(LpVectorType.REDIS);
        AiVectorService aiVectorService = aiVectorServiceOpt.get();
        System.out.println(aiVectorService);
        Optional<AiChatService> chatServiceOpt = aiChatServiceHandler.getByFactory(LpAiFactoryType.QIAN_FAN);
        AiChatService aiChatService = chatServiceOpt.get();
        ChatModel model = aiChatService.getChatModel(Collections.emptyMap());
        String msg = model.call("我叫朱迪");
        System.out.println(msg);
//        String msg = chatDemoController.function("获取指定地点的当前时间");
//        System.out.println(msg);
//        CustomerQianFanApiParams.TextToImageResponse response = chatModel.textToImage("鲜花");
//        System.out.println(response);
//        String msg = chatDemoController.chatMemory("我的名字是朱迪, 最喜欢吃巧克力", "1");
//        System.out.println(msg);
//        msg = chatDemoController.chatMemory("请问我叫什么名字，最喜欢吃什么", "1");
//        System.out.println(msg);
//        Map map = chatDemoController.openAiChat("我的名字是朱迪, 最喜欢吃巧克力");
//        System.out.println(map);
//        map = chatDemoController.openAiChat("请问我叫什么名字，最喜欢吃什么");
//        System.out.println(map);
    }

}
